import { TDramaCopy } from "../../../Message/Db/Tables/TDramaCopy";
import { TDrama } from "../../../Message/Db/Tables/TDrama";
import { EDramaType } from "../../../Message/Public/EDramaType";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class Lv70DramaConfig
    
    export  class Lv70DramaConfig
    {
        constructor()
        {
            
            this.initDramaCopy();
            this.initDrama();
            this._curCopy = this.getDramaCopy(3, 1, 1);
            return;
        }

        public Lv70DramaConfig.get curCopy(): TDramaCopy
        {
            return this._curCopy;
        }

        public set curCopy(arg1: TDramaCopy)
        {
            this._curCopy = arg1;
            return;
        }

        public getDrama(arg1: int, arg2: int): TDrama
        {
            var loc1=this.getDramaKey(arg1, arg2);
            return this._drama[loc1];
        }

        public getDramaCopy(arg1: int, arg2: int, arg3: int): TDramaCopy
        {
            var loc1=this.getDramaCopyKey(arg1, arg2, arg3);
            return this._dramaCopy[loc1];
        }

        public getChapterNum(arg1: int): int
        {
            var loc3=null;
            var loc1=0;
            var loc2=1;
            while (loc2 < 100000) 
            {
                if ((loc3 = this.getDramaCopy(loc2, arg1, 1)) == null) 
                {
                    break;
                }
                ++loc1;
                ++loc2;
            }
            return loc1;
        }

        public getLastDramaCopyByChapter(arg1: int, arg2: int): TDramaCopy
        {
            var loc1=null;
            var loc3=null;
            var loc2=1;
            while (loc2 < 100000) 
            {
                if ((loc3 = this.getDramaCopy(arg1, arg2, loc2)) == null) 
                {
                    return loc1;
                }
                loc1 = loc3;
                ++loc2;
            }
            return null;
        }

        public getNextLastSkipableDrama(arg1: TDrama): TDrama
        {
            var loc3=null;
            if (arg1.speedUp == 0) 
            {
                return arg1;
            }
            var loc1=arg1.step + 1;
            var loc2=arg1;
            while (loc1 <= 4000) 
            {
                if ((loc3 = this.getDrama(arg1.copyCode, loc1)) == null) 
                {
                    return loc2;
                }
                if (loc3.speedUp == 0) 
                {
                    return loc2;
                }
                loc2 = loc3;
                ++loc1;
            }
            return loc2;
        }

        public getBonusStep(arg1: int): int
        {
            var loc2=null;
            var loc1=1;
            while (loc1 < 1000) 
            {
                loc2 = this.getDrama(arg1, loc1);
                if (loc2 == null) 
                {
                    return 1;
                }
                if (loc2.type == EDramaType._EDramaReward) 
                {
                    return loc2.step;
                }
                ++loc1;
            }
            return 1;
        }

        /* internal  */initDrama(): void
        {
            var loc2=null;
            var loc3=null;
            this._drama = new Map<any, any> /* flash.utils.Dictionary */();
            var loc1=ConfigManager.instance.getJSONByFileName("t_drama.json");
            var loc4=0;
            var loc5=loc1;
            for(loc2 of loc5) 
            {
                loc3 = new TDrama();
                this.copyValue(loc3, loc2);
                this._drama[this.getDramaKey(loc3.copyCode, loc3.step)] = loc3;
            }
            return;
        }

        /* internal  */getDramaKey(arg1: int, arg2: int): string
        {
            return arg1.toString() + "_" + arg2.toString();
        }

        /* internal  */initDramaCopy(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            this._dramaCopy = new Map<any, any> /* flash.utils.Dictionary */();
            var loc1=ConfigManager.instance.getJSONByFileName("t_drama_copy.json");
            var loc5=0;
            var loc6=loc1;
            for(loc2 of loc6) 
            {
                loc3 = new TDramaCopy();
                this.copyValue(loc3, loc2);
                loc4 = this.getDramaCopyKey(loc3.chapter, loc3.difficulty, loc3.floor);
                this._dramaCopy[loc4] = loc3;
            }
            return;
        }

        /* internal  */getDramaCopyKey(arg1: int, arg2: int, arg3: int): string
        {
            return arg1.toString() + "_" + arg2.toString() + "_" + arg3.toString();
        }

        /* internal  */copyValue(arg1: Object, arg2: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg2;
            for (loc1 in loc3) 
            {
                arg1[loc1] = arg2[loc1];
            }
            return;
        }

        public static get instance(): Lv70DramaConfig
        {
            if (Lv70DramaConfig._instance == null) 
            {
                Lv70DramaConfig._instance = new Lv70DramaConfig();
            }
            return Lv70DramaConfig._instance;
        }

        /* internal */ /* const */FloorStartIndex: int=1;

        /* internal */ /* var */_drama: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_dramaCopy: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_curCopy: TDramaCopy;

        /* internal */ static /* var */_instance: Lv70DramaConfig;
    }
